package com.aote.reportforms;

import java.util.Hashtable;

import com.browsesoft.dbtools.DBTools;

/**
 * 报表工厂
 */
public class ReportformsFactory {

	private static ReportformsFactory self = new ReportformsFactory();

	/**
	 * 表名
	 */
	private static String tableName = "t_reportforms";

	private ReportformsFactory() {
	}

	public static ReportformsFactory getInstance() {
		return self;
	}

	/**
	 * 插入报表
	 */
	public void insert(String id, Hashtable attrs) {
		Reportforms report = new Reportforms(id, tableName, attrs);
		report.insert();
	}

	/**
	 * 更新报表
	 */
	public void update(String id, Hashtable attrs) {
		Reportforms report = new Reportforms(id, tableName, attrs);
		report.update();
	}

	/**
	 * 得到报表
	 */
	public Reportforms getReportforms(String id) {
		try {
			String sql = "select * from " + tableName + " where id = '"
					+ id + "'";
			String[][] datas = DBTools.executeQueryWithTableHead(sql);
			Hashtable ht = DBTools.getAttributes(datas, 1);
			Reportforms report = new Reportforms(id, tableName, ht);
			return report;
		} catch (Exception e) {
			return null;
		}
	}

}
